<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8" import="com.sfilyh.util.DBUtil" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
	request.setAttribute("nav", 2);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<link rel="stylesheet" type="text/css"  href="<%=request.getContextPath()%>/css/cssbase.css" />
<link rel="stylesheet" type="text/css" href="<%=request.getContextPath()%>/css/admin.css" />
<link rel="stylesheet" href="<%=request.getContextPath()%>/js/ueditor/themes/default/ueditor.css"/>
<script type="text/javascript">
	window.UEDITOR_HOME_URL = "<%=request.getContextPath()%>/js/ueditor/";
</script>	
</head>
<body>
<div class="header"></div>
<div class="content">
	<div class="left">
    	<h3 class="left_menu_title">操作菜单</h3>
        <jsp:include page="/WEB-INF/views/admin/left.jsp" />
    </div>
	<div class="right">
        <form action="<%=request.getContextPath()%>/bz-admin/addArticle" id="editor_form" method="post">
        <div class="right_body">        
        	<input type="hidden" name="status" />
			<input type="hidden" name="type" value="${doType}" />
			<c:if test="${doType == 'update'}">
			<input type="hidden" name="id" value="${article.id}" />	
			</c:if>
				        
            <div class="form_item">
                <div class="item_title">标题：</div>
                <div class="item_content">
                    <input type="text" class="input_txt" style="width:480px;" name="title" value="${article.title}"/>
                </div>
            </div>
            <div class="form_item">
                <div class="item_title">内容：</div>
                <div class="item_content">
                    <textarea id="myEditor" name="content" style="width:500px; height:290px;">${article.content}</textarea>                     
                </div>
            </div>
        </div>
        <div class="right_menu">
        	<h3>状态<span style="color: red;">&nbsp;
        		<c:choose>
        		<c:when test="${article.status == 0}">[已发布]</c:when>
        		<c:otherwise>[未发布]</c:otherwise>
        		</c:choose></span>
        	</h3>
        	        	
            <div class="right_menu_item"> 
            	<input type="submit"  value="存草稿" class="input_btn sub_btn" data-v="1" />
                <input type="button"  value="发布" class="input_btn sub_btn"	 data-v="0" />
            </div>
            <div class="right_menu_item">
            	<label>选择分类</label>
                <select name="category">
	                <c:forEach var="item" items="${categoryList}">
					<option value="${item.id}" <c:if test="${item.id == article.category}">selected="selected"</c:if>>${item.cname}</option>
					</c:forEach>                	
                </select>
            </div>
            <div class="right_menu_item">
            	<label>公开度</label>
                <p>密码：<input type="checkbox" name="ispass" value="1" <c:if test="${article.ispass == 1}">checked="checked"</c:if> /></p>
                <input type="text" name="password" value="${article.password}" />
            </div>
        </div>
        </form>       
    </div>     
</div>
</body>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/ueditor/editor_all_min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/ueditor/editor_config.js"></script>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
    $(document).ready(function(){
    	var editor = new baidu.editor.ui.Editor();
        editor.render("myEditor");
        $('.sub_btn').click(function(){
        	 $('input[name=status]').val($(this).data('v'));
        	 editor.sync(); 
        	 $('#editor_form').submit();
        });
    });
</script>
</html>
